import 'package:flutter/material.dart';

class Home extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('Stack'),
        leading: const Icon(Icons.menu),
        centerTitle: true,
        actions: const [Icon(Icons.settings)],
      ),
      body: const Center(child: StackDemo()),
    );
  }
}

class StackDemo extends StatelessWidget {
  const StackDemo({super.key});

  @override
  Widget build(BuildContext context) {
    const imageUrl =
        'https://patchwiki.biligame.com/images/yuan/thumb/7/70/4imkmvrv3671q7mtpsbjtbqa9r0g3sy.png/1350px-%E8%AF%B8%E8%91%9B%E8%AF%9E-%E7%AB%8B%E7%BB%98.png';

    return SizedBox(
      width: 400,
      height: 400,
      child: Stack(
        alignment: Alignment.center,
        children: [
          CircleAvatar(
            backgroundImage: NetworkImage(imageUrl),
            radius: 200,
            onBackgroundImageError: (_, __) =>
            const Icon(Icons.broken_image, size: 200),
          ),
          Positioned(
            top: 100,
            right: 60,
            child: Container(
              color: Colors.blue,
              padding: const EdgeInsets.all(10),
              child: const Text(
                '诸葛诞',
                style: TextStyle(color: Colors.white, fontSize: 20),
              ),
            ),
          ),
        ],
      ),
    );
  }
}